package com.qf.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

public class ReflectTest01 {

	
	public static void main(String[] args) {
		
		
		
		try {
			//通过全类名找到对应类的字节码对象
			Class clazz = Class.forName("com.qf.reflect.Student");
			
			Object obj = clazz.newInstance();
			
			
			
			
			
			Constructor<Student> con2 = clazz.getDeclaredConstructor(String.class);
			con2.setAccessible(true);
			
		
			//获取字符串有参构造器
			Object obj2=con2.newInstance("小明");
			
			System.out.println(obj2);
			
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch(Exception e) {
			e.printStackTrace();
			
		}
		
		
	}
}
